export default {
  data() {
    return {
      maxHeightDialog: this.getHeightAndWidth(),
      loading: false,
      detailObj: {},
      form: {},
      rules: {},
      submitLoading: false,
      emptyMessage: '*必填项不能为空'
    }
  },
  created() {},
  mounted() {},
  methods: {
    getHeightAndWidth() {
      let clientHeight = 0
      if (
        document.body.scrollHeight === window.screen.height &&
        document.body.scrollWidth === window.screen.width
      ) {
        clientHeight = window.screen.height - 5 // 网页可见区域高
      } else {
        clientHeight = document.body.clientHeight - 5 // 网页可见区域高
      }
      return clientHeight - 220 + 'px'
    },
    getValidatorForm(triggerType = 'blur') {
      return [
        { required: true, message: this.emptyMessage, trigger: triggerType }
      ]
    },
    dialogClose(key) {
      this[key].isVisible = false
    },
    formatFormData(formObj) {
      const model = {}
      // tslint:disable-next-line: forin
      for (const key in formObj) {
        model[key] = formObj[key] == null ? '' : formObj[key]
        if (typeof model[key] === 'string') {
          model[key] = model[key]
            .replace(/^(\s|\u00A0)+/, '')
            .replace(/(\s|\u00A0)+$/, '')
        }
      }
      return model
    },
    getFormatDate(dataStr, fmtstring) {
      if(dataStr && dataStr !='') {
        return this.$moment(new Date(dataStr)).format(fmtstring)
      }else {
        return ''
      }
     
    }
  }
}
